doctype html
html(lang="en" ng-app="3drepo").ng-scope
	script(type="text/javascript", src="/config.js")
	link(rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic")
	style.
		html, body {
				font-family: Roboto, sans-serif;
		}
		table {
			border-collapse: separate;
			border-spacing: 10px;
		}
		.bold {
			font-weight: bold;
		}
	head
		each issueTypeIssues, issueType in issues
			if issueType === "open" && issueTypeIssues.length > 0
				h2 Open Issues
			else if issueType === "closed" && issueTypeIssues.length > 0
				h2 Closed Issues

			// TODO: Time stamps - What is going on here?!
			each issue in issueTypeIssues.sort((a, b) => { return new Date(b.created).getTime() - new Date(a.created).getTime()  } )
				hr
				table(border=0)
					tr
						td(colspan=2)
							h3 ##{issue.number} #{issue.name}
					if issue.viewpoint.screenshotSmall
						tr
							td(colspan=2) 
								a(href=url(issue.viewpoint.screenshot) target='_blank')
									img(src=url(issue.viewpoint.screenshotSmall))

					tr
						td(colspan=2)
							b Assigned:
							span [#{issue.assigned_roles.join(", ")}] 

							b Priority: 
							span #{issue.priority} 

							b Status: 
							span #{issue.status} 

							b Type: 
							span #{issue.topic_type}

					tr
						td(colspan=2)
							b Description: 
							span #{issue.desc}
					tr
						td
							span.bold #{issue.owner} 
							span [#{new Date(issue.created).toUTCString()}]
						td Issue Opened....
					if issue.comments
						each comment in issue.comments
							tr
								td
									span.bold #{comment.owner} 
									span [#{new Date(comment.created).toUTCString()}]
								td 
									if comment.comment
										| #{comment.comment}
									if comment.action
										| #{comment.action.propertyText} changed from 
										i #{comment.action.from} 
										| to 
										i #{comment.action.to}
							if comment.viewpoint && comment.viewpoint.screenshotSmall
								tr
									td(colspan=2)
										a(href=url(comment.viewpoint.screenshot) target='_blank')
											img(src=url(comment.viewpoint.screenshotSmall))
								
				br

